<?php 
	function create_token($token){
		$timestamp = time();
		$_SESSION[$token] = $timestamp;
		return md5($timestamp);
	}
	function valid_token($token) {
		if (isset( $_SESSION[$token]) && isset($_POST[$token]) && $_POST[$token] == md5($_SESSION[$token])){
			$_SESSION[$token] = '';
			return true;
		}
		return false;
	}
?>